# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=jicofo
pkgver=2.0.8719
# the releases prefix the tag
_pkgver="jitsi-meet_${pkgver##*.}"
pkgrel=0
pkgdesc="Jitsi meet conference focus"
url="https://github.com/jitsi/jicofo"
arch="x86_64"
license="Apache-2.0"
depends="openjdk11-jre-headless prosody bash"
makedepends="maven"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/jitsi/jicofo/archive/refs/tags/stable/$_pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	sip-communicator.properties
	"
options="!check" # No test suite

builddir="$srcdir/jicofo-stable-$_pkgver"

build() {
		export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
		export PATH=$JAVA_HOME/bin:$PATH
		mvn -DskipTests -Dassembly.skipAssembly=true clean package install
		mvn dependency:copy-dependencies -DincludeScope=runtime
}

package() {
	DESTDIR="$pkgdir"/usr/lib/$pkgname
	CONFDIR="$pkgdir"/etc/jitsi/jicofo

	# dependencies, libraries and java launch files
	install -Dm644 -t "$DESTDIR"/lib ./*/target/dependency/*
	install -Dm644 jicofo/target/jicofo*.jar "$DESTDIR"/jicofo.jar
	install -Dm755 -t "$DESTDIR" resources/jicofo.sh
	install -Dm755 -t "$DESTDIR" resources/collect-dump-logs.sh

	# configuration
	install -dm700 "$CONFDIR"
	install -Dm644 "$srcdir"/sip-communicator.properties "$CONFDIR/sip-communicator.properties"
	install -Dm640 -t "$CONFDIR" "lib/logging.properties"
	install -Dm600 jicofo-selector/src/main/resources/reference.conf "$CONFDIR/jicofo.conf"

	# init scripts and logrotate
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
}

sha512sums="
4342bd87139fc61deca80666c325818f0f626bea97aa448bbe07561f81c348a29b75ccc345535e6031440fc6613466cfb272ac087389bd4d490facb68f23ae83  jicofo-2.0.8719.tar.gz
5004fc2b8cd008831551dd2012f353eb515952a7a326dee38e0a6d957123bd75eda6f727c05dfaee8e22e340e792a0aa8f8786b20fdf5e5eaf40bad01ee40d4e  jicofo.initd
682a80c483dbaf379d03a4cc02e48de4f4485364f41d62cb503dbd21426a4ba92a2e56f531956a85800209d8299e4cb57dd6a66e7974072a655ad63800f4fe54  jicofo.confd
64f34dafc1062187485671a29fa147d651c050d9b52331c2933c6c3f024654cd02961d40b1d178e70d2cac9107be4f881654be871423c27459ef6669bcd5402c  jicofo.logrotate
4d87dce61ab19920f9b790ddf52aa8057f17ad0657a5a763efeebd5df2bd51758baffd5167355421ccd9e21b4e87fbaac6210f11e4c31d6beb0a890ea3ff2486  sip-communicator.properties
"
